﻿/**
 * ...
 * @author 
 */
package list;

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import gui.hug.HUGButton;
import gui.hug.HUGSprite;
import gui.hug.priv.HUGTextField;
import gui.hug.HUGEditField;
import flash.events.MouseEvent;


class SearchPanel extends HUGSprite {
     
	static private inline var wid  : UInt = 150; 
	static private inline var t    : UInt = 10;
	static private inline var l    : UInt = 10;
	static private inline var h    : UInt = 20;
	
	private var button		:HUGButton;
	private var editField	:HUGEditField;
	
	public function new(left : UInt = 0, top : UInt = 0, onClick: String -> Void) {
		super();
		setLocation(left, top);
		
		editField = new HUGEditField();
	    editField.setSize(Std.int(wid), h);
		editField.setLocation(l + left, t);
		
		var me = this;
		button = new HUGButton("Поиск");
		button.setLocation(l + left + wid + l, t);
		
		editField.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent) { if (e.keyCode == Keyboard.ENTER) onClick(me.editField.getText()); } );
		button.addEventListener(MouseEvent.CLICK, function(e) { onClick(me.editField.getText()); } );
       
		addChild(editField);
		addChild(button);
	}
	
	
}
	
